package com.example.dockerdemo.controller;

import com.example.dockerdemo.entity.Goods;
import com.example.dockerdemo.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class GoodsController {
    @Autowired
    private GoodsService goodsService;

    @GetMapping("/goods/{id}")
    public Goods getGoods(@PathVariable("id") Long goodsId) {
        Goods goods = goodsService.selectById(goodsId);
        return goods;
    }

    @GetMapping("/redisgoods/{id}")
    public Goods getRefisGoods(@PathVariable("id") Long goodsId) {
        Goods goods = goodsService.selectFromRedis(goodsId);
        return goods;
    }

    @GetMapping("/hello/{name}")
    public String hello(@PathVariable("name") String name){
        return "hello,"+name;
    }
}
